/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.agh.student.logic.service;

import java.util.List;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import pl.edu.agh.student.logic.dao.GenericDao;
import pl.edu.agh.student.logic.dao.RoleDao;
import pl.edu.agh.student.model.Role;

/**
 *
 * @author janburkot
 */
@Name("roleService")
public class RoleServiceImpl extends GenericServiceImpl<Role> implements RoleService {

    @In(value="roleDao",create=true,required=false)
    @Out
    protected RoleDao dao;
    
    @Override
    public GenericDao<Role> getDao() {
        return dao;
    }


    public Role findRoleByName(String name) {
        List<Role> roles = dao.findByProperty("name", name);
        
        return (roles.size()>0)?roles.get(0):null;
    }

}
